/**
 * 
 */
package ro.dta.idbi.ui.sql;

import ro.dta.idbi.interfaces.sql.ISqlConstruct;

import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGeometry;

import uk.ac.ic.doc.automed.reps.Schema;
import uk.ac.ic.doc.automed.reps.SchemaObject;

/**
 * Sql Construct JGraph cell
 * 
 * @author Tudor Dobrila
 * 
 */
public abstract class AbstractSqlCell extends mxCell implements Cloneable, ISqlConstruct {

	private static final long serialVersionUID = 7261296668943427310L;

	protected transient Schema schema;

	protected transient SchemaObject schemaObj;

	/**
	 * mxSqlConstruct class constructor
	 * 
	 * @param schemaObj
	 *            AutoMed Schema object associated with this construct
	 * @param cellId
	 *            ID of construct
	 * @param value
	 *            Value of cell
	 * @param geometry
	 *            Geometry description of the construct
	 * @param style
	 *            Style of the cell
	 */
	public AbstractSqlCell(final Schema schema, final SchemaObject schemaObj, final String cellId,
			final String value, final mxGeometry geometry, final String style) {
		super();
		this.schema = schema;
		this.schemaObj = schemaObj;

		if (geometry != null) {
			setGeometry(geometry);
		}
		setStyle(style);
		setValue(value);
		setId(cellId);
		setConnectable(true);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see ro.dta.idbi.sql.ui.ISqlConstruct#getSchemaObject()
	 */
	@Override
	public SchemaObject getSchemaObject() {
		return schemaObj;
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		final AbstractSqlCell obj = (AbstractSqlCell) super.clone();
		obj.schema = schema;
		obj.schemaObj = schemaObj;
		return obj;
	}
}
